package com.shinewind.info.controller;

import cn.hutool.core.util.BooleanUtil;
import cn.hutool.core.util.ObjectUtil;
import com.shinewind.common.constant.messageConstant;
import com.shinewind.home.service.IModelService;
import com.shinewind.home.service.INewsService;
import com.shinewind.info.service.IArticleService;
import com.shinewind.pojo.entity.*;
import com.shinewind.pojo.result.Result;
import com.shinewind.pojo.vo.ArticleVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Optional;

@RestController
@RequestMapping("/modelEvaluating")
@Api(value = "评测接口",description = "用于展示模型的评测文章等信息")
public class ArticleController {
    @Autowired
    private IArticleService iArticleService;
    @DubboReference
    private INewsService iNewsService;
    @DubboReference
    private IModelService iModelService;

    @GetMapping("/article/{mId}")
    @ApiOperation(value = "文章信息",notes = "文章信息",response = Result.class)
    public Result getArticleById(@PathVariable("mId") String mId){
        ArticleVo articleVo = iArticleService.getArticleByMid(mId);
        return Result.success(articleVo, BooleanUtil.isTrue(ObjectUtil.isNotNull(articleVo)),
                messageConstant.QUERY_SUCCESS);
    }
}